package live.zs.tkmybatisboot.service.impl;

import live.zs.tkmybatisboot.entity.TbUser;
import live.zs.tkmybatisboot.repo.TbUserMapper;
import live.zs.tkmybatisboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author madison
 * @description
 * @date 2021/7/8 23:31
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private TbUserMapper userMapper;

    @Override
    public List<TbUser> selectUsers() {
        Example example = Example.builder(TbUser.class).orderByDesc("createTime").build();
        List<TbUser> tbUsers = userMapper.selectByExample(example);
        return tbUsers;
    }

    @Override
    public int saveUser(TbUser user) {
        return userMapper.insertSelective(user);
    }
}
